<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>画一个矩形</title>
</head>
<script language="JavaScript">
    function init() {
        var canvas = document.getElementById("output");
        var context = canvas.getContext("2d");
        canvas.clientWidth = window.innerWidth;
        canvas.clientHeight = window.innerHeight;
        context.fillStyle = "#ff0000";
        context.fillRect(10, 10, 500, 600);
        context.fill();
    }
    window.onload = init;
</script>

<body>
    <canvas id="output"></canvas>
</body>

</html>